<%@page language="java" pageEncoding="UTF-8" contentType="text/html;charset=utf-8"%>
<%@include file="/includes/taglibs.jsp"%>
<%@page import="com.feib.soeasy.util.UserUtil"%>
<%@page import="com.feib.soeasy.util.CodeTableUtil"%>
<%@page import="com.feib.soeasy.model.Payment"%>
<%@page import="com.feib.soeasy.action.Soez1007ActionBean"%>

<script type="text/javascript">
<!--
$(document).ready(function() {	
});
//-->
</script>
<div id="queryNothingBlockDiv" style="display: none;">
	<% 
	Soez1007ActionBean actionBean = (Soez1007ActionBean)request.getAttribute("actionBean");
	Payment payment = actionBean.getResultPayment();

    pageContext.setAttribute("messageTitle", "線上繳款");
    pageContext.setAttribute("showDialog", true);
    
	if (null == payment)
	{
	    out.println("查無資料");
	}
	else
	{
	    boolean singlePrice = true;
	    if (Payment.PAYMENT_STATUS_IN_PAYING.equals(payment.getPaymentStatus()))
		{
		    if (null != payment.getTotalLoanableAmount() && 0 != payment.getTotalLoanableAmount().longValue())
		        singlePrice = false;
		    
		    if (singlePrice)
		    {
			    pageContext.setAttribute("showDialog", false);
		        
	%>
		<form id="callWebAtmHiddenFrom" action="http://ebank-t.feib.com.tw/netbank/servlet/TrxDispatcher" method="post" target="_blank" accept-charset="big5" onsubmit="document.charset='big5';">
		<input type="hidden" name="trx" value="com.lb.wibc.trx.WebATMeBillingPayC"/>
		<input type="hidden" name="state" value="prompt"/>
		<input type="hidden" name="channelType" value="<c:out value='${actionBean.realAccount.partnerNo }'/>"/>
		<input type="hidden" id="hidden.txAmt" name="TxAmt" value="<c:out value='${actionBean.resultPayment.totalAmount }'/>"/>
		<input type="hidden" name="TxMemo" value="<c:out value='${actionBean.resultPayment.paymentName }'/>"/>
		<input type="hidden" name="CancelNo" value="<c:out value='${actionBean.resultPayment.virtualAccount }'/>"/>
		</form>
		
	<% 
		    }
		    else
		    {
		        // 兩個價錢，須顯示在畫面上提供選擇
		        pageContext.setAttribute("messageTitle", "請選擇繳款金額");
		        
	%>
		<form id="callWebAtmHiddenFrom" action="http://ebank-t.feib.com.tw/netbank/servlet/TrxDispatcher" method="post" target="_blank" accept-charset="big5" onsubmit="document.charset='big5';">
		<input type="hidden" name="trx" value="com.lb.wibc.trx.WebATMeBillingPayC"/>
		<input type="hidden" name="state" value="prompt"/>
		<input type="hidden" name="channelType" value="<c:out value='${actionBean.realAccount.partnerNo }'/>" />
		<input type="hidden" id="hidden.txAmt" name="TxAmt" value=""/>
		<input type="hidden" name="TxMemo" value="<c:out value='${actionBean.resultPayment.paymentName }'/>" />
		<input type="hidden" name="CancelNo" value="<c:out value='${actionBean.resultPayment.virtualAccount }'/>" />
		
		<input type="button" id="pay1Btn" value="<c:out value='${actionBean.resultPayment.totalAmount }'/>" / >
		<input type="button" id="pay2Btn" value="<c:out value='${actionBean.resultPayment.totalLoanableAmount }'/>"  / >
		</form>
		
	<%
		    }
		}
	    else if (Payment.PAYMENT_STATUS_CLOSED.equals(actionBean.getResultPayment().getPaymentStatus()))
		    out.println("此繳費單已繳款");
		else if (Payment.PAYMENT_STATUS_CANCELED.equals(actionBean.getResultPayment().getPaymentStatus()))
		    out.println("此繳費單已註銷");
	}
		
	%>
</div>

<script type="text/javascript">
<!--
$(document).ready(function() {
	$("#pay1Btn").click(function() {
		$("#hidden\\.txAmt").val($("#pay1Btn").val());	
		$("#callWebAtmHiddenFrom").submit();	
		$("#webAtmResultDiv" ).dialog( "close" );
	});
	
	$("#pay2Btn").click(function() {
		$("#hidden\\.txAmt").val($("#pay2Btn").val());
		$("#callWebAtmHiddenFrom").submit();
		$("#webAtmResultDiv" ).dialog("close");
	});
	<c:if test="${showDialog == true}">
	$("#queryNothingBlockDiv" ).show();
	$( "#webAtmResultDiv" ).dialog({  title:"<c:out value='${messageTitle}'/>" ,width: 300, resizable: false, modal: true
		, buttons : {
		Ok : function() {
			$(this).dialog("close");
			}
		}  
	});
	</c:if>
	<c:if test="${showDialog == false}">
	$("#queryNothingBlockDiv" ).hide() ;
	$("#callWebAtmHiddenFrom").submit();
	</c:if>
});
//-->

	
	
</script>
